<?
 include ("header.php");
session_start();
 include ("../header.php");
?>

<table border="1" align="center">
<?
$sql = mysql_query("SELECT*FROM news");
      while($record = mysql_fetch_array($sql))
   {
  print '<tr><td>'.$record['title'].'</td>
  <td><a href="editor.php?page_title='.$record['title'].
  '">Редактировать</a></td>
  <td><a href="editor.php?page_title='.$record['title'].'&delete=y">Удалить</a></td>
  </tr>';
   }
?>
</table>
<?

$sql = mysql_query("select * FROM pages where title='".$page_title."';");
  while($record = mysql_fetch_array($sql))
  {
   $content=$record['content'];
  }
if($save)
   $sql =mysql_query ("UPDATE pages SET content = '".$text_edit."' WHERE title='".$_SESSION['id']."';");
if($delete)
   $sql =mysql_query ("DELETE FROM pages WHERE title='".$_SESSION['id']."';");
?>
<form action="editor.php" method="post">
<table width="100%"  align="center">
  <tr>
    <td align="center"><textarea name="text_edit" cols="80" rows="15"><? print $content; ?></textarea></td>
  </tr>
  <tr>
    <td align="center"><input name="save" type="submit" value="Сохранить"></td>
  </tr>
</table>
</form>
<?
  $_SESSION['id']= $page_title;
?>
